<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="ddiir">
<meta name="keyword" content="databases,experiments">
<link rel="shortcut icon" href="/rucdbcourse/views/images/ruc_logo_icon.jpg">
<title>数据库系统概论实验评分系统</title>
<!-- Bootstrap core CSS -->
<link href="/rucdbcourse/views/css/bootstrap.min.css" rel="stylesheet">
<link href="/rucdbcourse/views/css/bootstrap-reset.css" rel="stylesheet">
<!--external css-->
<link href="/rucdbcourse/views/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
<!-- Custom styles for this viewPage -->
<link href="/rucdbcourse/views/css/style-login.css" rel="stylesheet">
<link href="/rucdbcourse/views/css/style-responsive.css" rel="stylesheet" />
<link href="/rucdbcourse/views/assets/layer/skin/layer.css" rel="stylesheet" />		    
<!-- jQuery --> 
<script type="text/javascript" src="/rucdbcourse/views/js/jquery.js"></script> 
<script type="text/javascript" src="/rucdbcourse/views/lib/angular.min.js"></script>
<!-- Page walkthrough plugin --> 
<script type="text/javascript" src="/rucdbcourse/views/js/vCode.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
<!--[if lt IE 9]>
    <script src="views/js/html5shiv.js"></script>
    <script src="views/js/respond.min.js"></script>
    <![endif]-->
</head>

<body class="login-body">
<!-- 页面加载时遮罩层 -->
	<div id="mask"  style=" position: absolute; top: 0; left: 0; width: 100%; height: 100%;background-color:rgba(0,0,0,0.3);z-index:9999"></div>
<!-- 遮罩层结束 -->
<!-- 顶栏 -->	
	<div class="header">
	 	<img src="/rucdbcourse/views/images/ruc_logo.png" class="header-pic"> 
	 	<button class="btn" onClick="javascript:window.location.href='/rucdbcourse/views/tlogin.html'" style="margin-left:950px;margin-top:5px">教师登录</button>
	 	<button class="btn" onClick="javascript:window.location.href='/rucdbcourse/views/mindex.html'" style="margin-left:1250px;margin-top:-60px">管理员登录</button> <!-- 发行版本要继续修改 -->
	</div>
<!-- 顶栏结束 -->
<!-- 页面主体 -->
	<div class="container">
		<div class="login_pictures">
			<div id="login-bg" class="login_pictures_picture"></div>
			<div class="login_pictures_txt" id="login-txt-block">
				<p class="login_pictures_title">欢迎使用数据库系统概论实验评分系统！</p>
				<p id="login-txt"></p>
			</div>
		</div>

		<div class="form-signin" ng-app="signin" ng-controller="signinCtrl">
			<h2 class="form-signin-heading">账号登录</h2>
			<div class="login-wrap">
				<input type="text" ng-model="name" id="uid" name="userid" class="form-control" placeholder="请输入账号" autofocus> 
				<input type="password" ng-model="passwd" name="password" id="upsw" class="form-control" placeholder="请输入密码"> 
				<input style="float:left;width:40%;vertical-align:middle;" type="text" ng-model="verifycode" name="veryCode" id="veryCode" class="form-control" placeholder="验证码">
                <div id="vCode1" style="width:100px; height: 46px; margin-left: 20px;margin-top: 11px; border: 1px solid #ccc; display: inline-block;"></div>
				<button class="btn btn-lg btn-login btn-block" ng-click="submits()" id="login-btn">登&nbsp;&nbsp;&nbsp;&nbsp;录</button>
				<div class="login_input2" style="color:#b6b6b6;">
 					还没有注册?&nbsp&nbsp<a href="javascript:window.location.href='/rucdbcourse/views/sign-up.html'" style="color: #C43C3C;">立即注册</a>
					<a style="float:right;" href="javascript:window.location.href='/rucdbcourse/views/reset-password.html';">忘记密码</a>
				</div>
			</div>
		</div>	
	</div>
<!-- 页面主体结束 -->
<!-- 页脚 -->
	<div class="footer">
		<div class="container">
				Copyright &copy;2005-2017 ruc.edu.cn v1.0 All Rights Reserved.
				京ICP备05066828号-1<br>
		</div>
	</div>
<!-- 页脚结束 -->
<script src="/rucdbcourse/views/assets/layer/layer.js"></script>
<script type="text/javascript" src="/rucdbcourse/views/js/verifyCode.js"></script>
<script>
	//捕获键盘点击事件
	$(function(){
		document.onkeydown = function(e){ 
		    var ev = document.all ? window.event : e;
		    if(ev.keyCode==13) {
		    	$("#login-btn").click();
		     }
		}
	});
	
	var app = angular.module('signin', []);
    app.controller('signinCtrl', function($scope, $http) {
    	//验证码
        var container1 = document.getElementById("vCode1");
        var code1 = new vCode(container1);

        $scope.submits = function() {
        	if($scope.name==null){
    			layer.msg('用户名不能为空');
    			return false;
    		}else if($scope.passwd==null){
    			layer.msg('密码不能为空！');
    			return false;
    		}else if($scope.verifycode==null){
    			layer.msg('请填写验证码');
    			return false; 
    		}else if(!code1.verify(document.getElementById("veryCode").value)){
            	layer.msg('验证码错误');
            	return false; 	
            }else{
    			$("#login-btn").attr("disabled",true);
        		$("#login-btn").html("登录中...");
                // console.log("submit")
                $http.post('user/login',
               		$.param({
    					name: $scope.name,
    					passwd: $scope.passwd
    				}), {
    					headers: {
    					    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
    					}
                }).then(function(response) {
    				// debugger
    				// console.log(response.data.value)
    				var result = response.data.value;
    				if (result == 'success') {
    				    // debugger
    				    // console.log(response.data.value);
    				    $("#login-btn").attr("disabled",false);
    					$("#login-btn").html("登&nbsp;&nbsp;&nbsp;&nbsp;录");
    				    window.location = "/rucdbcourse/views/index.html";
    				} else {
    					if(result=="passwd_err"){
                        	result="密码错误";
                        }else if(result=="user_not_exist"){
                        	result="用户不存在";
                        }else if(result=="waiting"){
                        	result="请等待老师审核";
                        	window.location="/rucdbcourse/views/info.html?type=1";
                        }else if(result=="rejected"){
                        	result="您的申请已被拒绝";
                        }
    				    layer.msg(result);
    				    $("#login-btn").attr("disabled",false);
    					$("#login-btn").html("登&nbsp;&nbsp;&nbsp;&nbsp;录");
    				    // console.log(response.data.msg);
    				}
    			});
    		}
        };
    }); 
</script>

<script type="text/javascript">
	//页面加载时显示遮罩层
	window.onload = function(){
		$("#mask").css("display","none");
	}
	var url;
	$(document).ready(function(){
		var randomNum = Math.random()*5;
		//var r=Math.ceil(randomNum);
		var r = 6;
		document.getElementById("login-txt").innerHTML="亲爱的同学，你好！<br/>欢迎选修“数据库系统概论（基础篇）”课程。<br/>课程的第11讲SQL概述与数据定义、第12讲数据查询—单表查询实验已经上线，欢迎参加实验测验~~~<br/> 记得参加讨论区的讨论奥~~~<br/>祝你学习愉快！<br/>by 数据库君  <2017年3月17日><br/>";
		if(r==1){
			document.getElementById("login-bg").style.backgroundImage="url(/rucdbcourse/views/images/bg1.jpg)";
			document.getElementById("login-txt-block").style.paddingLeft="400px";	
		}else if(r==2){
			document.getElementById("login-bg").style.backgroundImage="url(/rucdbcourse/views/images/bg2.jpg)";
			document.getElementById("login-txt-block").style.paddingLeft="300px";
		}else if(r==3){
			document.getElementById("login-bg").style.backgroundImage="url(/rucdbcourse/views/images/bg3.jpg)";
			document.getElementById("login-txt-block").style.paddingLeft="0px";
		}else if(r==4){
			document.getElementById("login-bg").style.backgroundImage="url(/rucdbcourse/views/images/bg4.jpg)";
			document.getElementById("login-txt-block").style.paddingLeft="10px";
		}else if(r==5){
			document.getElementById("login-bg").style.backgroundImage="url(/rucdbcourse/views/images/bg5.jpg)";
			document.getElementById("login-txt-block").style.paddingLeft="350px";
		}else if(r==6){
			document.getElementById("login-bg").style.backgroundImage="url(/rucdbcourse/views/images/bg6.png)";
			document.getElementById("login-txt-block").style.paddingLeft="50px";
		}
	});
</script>
</body>
</html>
